<template>
  <div class="add-desk">
    <mt-header :title="title">
      <router-link to="/shop" slot="left">
        <mt-button icon="back">返回</mt-button>
      </router-link>
    </mt-header>

    <div class="add-desk-list">
      <mt-field label="包邮金额" placeholder="最低多少元可以免邮费" v-model="minMoney"></mt-field>
      <mt-field label="包邮公里" type="text" placeholder="多少公里内可包邮" v-model="km"></mt-field>
      <mt-field label="追加单价" type="text" placeholder="超过每公里加多少元" v-model="qian"></mt-field>
      <mt-button class="btn-tj" type="primary" @click="tj">提交</mt-button>
    </div>

  </div>
</template>

<script>
import axios from 'axios'
import { Toast } from 'mint-ui'
import { check_empty } from 'common/js/help.js'
import { axiosNet } from 'common/js/nethelp.js'
export default {
  data() {
    return {
      minMoney: '',
      km: '',
      qian: '',
      title: '配送费管理'

    }
  },
  mounted() {
    let token = localStorage.getItem("access_token");
    let params = { "access_token": token}
    axiosNet("/Shop/get_deliver_fee", params, (data) => {
      let info = data.data.info
      this.minMoney = info.order_fee
      this.km = info.distance
      this.qian = info.distance_fee
    })

  },
  methods: {
    tj() {
      if (check_empty(this.minMoney)) {
        Toast({
          message: '包邮金额不能是空'
        });
        return
      }
      let token = localStorage.getItem("access_token");
      let params = {
        "access_token": token,
        "order_fee":this.minMoney,
        "distance":this.km,
        "distance_fee":this.qian
      }
      axiosNet("/Shop/init_deliver_fee", params,(data) => {
        this.$router.push('/shop')
      })
    }
  },
  components: {
  }
}
</script>

<style lang="stylus">
.add-desk
  background:#f2f2f2
  height:100%
  width:100%
  position:absolute
  top:0
  left:0
  z-index:10
  .mint-header
    color:rgb(104, 104, 104)
    background:#26a2ff
    border-bottom:1px solid #ccc
    font-size:18px
    letter-spacing:2px
    box-shadow: 1px 3px 5px #eee
    color:#fff
    height 44px
    label,span
      color:#fff
  .add-desk-list
    .mj
      display: flex
      background: #fff
      border-bottom: 1px solid #f1f1f1
      padding 0 10px
      .title-p
        flex: 0 0 105px
        padding-top: 10px
        color: #111
      .mj-input
        flex: 1
        display: flex
        p
          line-height:40px
          color:#f00
          flex: 0 0 50px
          text-align: center
        input
          min-height: 40px
          height: 40px
          border-bottom: none
    .btn-tj
      margin:20px 5%
      width:90%
    .mint-field 
      border-bottom:1px solid #f1f1f1

  .mint-popup-bottom
    width:100%

</style>